<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var date1 = new Date();
    var year = date1.getFullYear();
    //获取的月份的取值范围是0-11
    var month = date1.getMonth();//范围0-11
    month = month+1;
    
    //获取星期 日期对象.getDay();
    //得到的是索引值
    //获取日期的取值范围0-6
    //每个星期的第一天是星期日
    var weekday = date1.getDay();
    //定义数组
    var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
    console.log(year,month,weeks[weekday]);

    //getDate()获取今天的日期
    var day = date1.getDate();
    console.log(day);

    //获取时、分、秒
    var hour = date1.getHours();
    var minute = date1.getMinutes();
    var sec = date1.getSeconds();
    console.log(hour,minute,sec);
</script>
</html>